using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player_Health : Entity_Health, ISaveable
{

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.M))
            Dead();
    }
    public void EnableHealthBarInHead(bool toggle)
    {
        headBar?.transform.parent.gameObject.SetActive(toggle);
    }
    public override void Dead()
    {
        base.Dead();
        Player.Instance.uI.OpenGameOverUI();
    }

    public void SaveData(ref GameData gameData)
    {
        gameData.playerHealth.Clear();
        if (isDead)
            gameData.playerHealth.Add(entityStat.GetMaxHealth());
        else
            gameData.playerHealth.Add(currentHealth);
    }

    public void LoadData(GameData gameData)
    {
        if (gameData.playerHealth.Count == 0)
            return;
        currentHealth = gameData.playerHealth[0];
        TriggerOnHealthChange();
    }
}
